Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derived fields should respect causality region + Improve tests #5488

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

incrypto32
Copy link
Member

Closes #5267

@incrypto32 incrypto32 force-pushed the krishna/fix-derived-with-fds branch from 78d9467 to dbd7a64 Compare June 18, 2024 08:43
@fordN fordN requested a review from zorancv June 25, 2024 15:39
Copy link
Contributor

@zorancv zorancv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool that we can do a test with a blockchain!


const ONCHAIN_FROM_OFFCHAIN = "CREATE_ONCHAIN_DATASOURCE_FROM_OFFCHAIN_HANDLER";
const CREATE_FILE = "CREATE_FILE";
// const CREATE_FILE_FROM_HANDLE_FILE = "CREATE_FILE_FROM_HANDLE_FILE";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove it, if its not used.

@@ -90,6 +90,7 @@ impl DerivedEntityQuery {
/// Checks if a given key and entity match this query.
pub fn matches(&self, key: &EntityKey, entity: &Entity) -> bool {
key.entity_type == self.entity_type
&& key.causality_region == self.causality_region
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love short implementations!

let hash = context.getString("hash");
log.info("Creating file data source from handleFile: {}", [hash]);
dataSource.createWithContext("File", [hash], new DataSourceContext());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's idiomatic for TypeScript bu wouldn't else if look more like a switch statement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it should have been an else if.

We cannot use switch cases though since switch-case in assemblyscript does not work with string
AssemblyScript/assemblyscript#1643

@zorancv zorancv changed the title Dervied fields should respect causality region + Improve tests Derived fields should respect causality region + Improve tests Jun 27, 2024
entity.content = data.toString();
entity.save();
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove a nesting level by doing this block if not command and returning. Then you know all the rest are commands. as zoran said it's prolly more of a switch case, mostly for making it a bit easier to maintain and read if you think it's worth. But also none of the ifs return when match so that could create some weird test situations 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, making the change.

@incrypto32 incrypto32 force-pushed the krishna/fix-derived-with-fds branch from 96a3d38 to c0b4cb0 Compare July 9, 2024 09:28
@incrypto32 incrypto32 merged commit 0530ce1 into master Jul 9, 2024
7 checks passed
@incrypto32 incrypto32 deleted the krishna/fix-derived-with-fds branch July 9, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Derived loaders does not respect causality regions
3 participants